The present invention relates generally to code packing in a digital video system and more particularly to the arrangement of compressed video segment data in a storage device.
Over the past few years, digital technology has been used with cellular telephones, cameras, and video recorders. In particular, handheld video recorders store a number of frames in a particular sequence for playback at a later time. The sequence of frames collectively form a video signal. The video signal is generally converted from analog to digital using an analog to digital converter to produce a digital video signal. Digital video signals can be divided into a number of video segments. A video segment may be made up of a number of pixel values.
FIG. 1 illustrates the arrangement of compressed video segment data in a storage device using the Digital Video Standard. Storage device 100 describes a memory space that is used to store the compressed video segment data. Storage device 100 has five macro-blocks indicated as MB101, MB102, MB103, MB104, and MB105. Each macro-block has six blocks designated as block 101a, block 101b, block 101c, block 101d, block 101e, and block 101f. Blocks 101a, 101b, 101c, and 101d each have a memory storage capacity of 14 bytes. Each 14 byte block represents an eight by eight matrix that stores sixty-four pixel values (see FIG. 2). Arrows in FIG. 2 illustrate an order for reading pixel values. Those with ordinary skill in the art would understand that pixels can be read in different orders. Blocks 101e and 101f each have a memory storage capacity of 10 bytes. Each 10 byte block represents an eight by eight matrix storing sixty-four pixel values. Each pixel value may be represented using a number of bits (e.g., 8 bits).
The Digital Video (xe2x80x9cDVxe2x80x9d) specification, defined by the xe2x80x9cDV Standardxe2x80x9d or xe2x80x9cBlue Bookxe2x80x9d Standard, describes the arrangement algorithm for a video segment into a storage device. The DV Standard is included herein by reference in its entirety and for all purposes. The DV specification has documented the arrangement algorithm of a video segment into a storage device which requires three passes. Arranging a video segment using three passes indicates that three loops are required to pack each video segment into a designated location (e.g., memory, buffer). Typically, the video data is compressed and then packed into the designated location.
During pass one, compressed data is packed into a macro-block, e.g., MB101. The packing is accomplished by filling the first block, e.g., block 101a, with compressed data. Two results may arise when filling a single block. First, the compressed data may completely fit into the block. That is, all the compressed data can be stored in the first block and the block is terminated with an end of block (xe2x80x9cEOBxe2x80x9d) token 106. A block that can hold all the compressed data is referred to as a finished block. Second, the compressed data may not completely fit into a block. Hence, there is some overflow data from the same block. In this situation, the compressed data may completely fill the block and the remaining overflow data could not be stored in the block. The overflow data will be stored in a separate memory and will not be stored into the memory block until pass two or pass three. Each block having overflow data is referred to as an unfinished block. After block 101a is packed, block 101b, block 101c, block 101d, block 101e, and block 101f are packed successively. After the first macro-block MB101 is filled, that is blocks 101a through 101f are either filled with an EOB token 106 or completely filled and having additional overflow data stored in separate memory, macro-block 102, macro-block 103, macro-block 104, and macro-block 105, are filled in the same manner as macro-block 101. For each block, all the compressed overflow data is stored in the separate memory until pass two or pass three.
In pass two, the overflow data from macro-block 101 is retrieved from the separate memory. The overflow data from macro-block 101 is filled into a finished block in the same macro-block, that is macro-block 101. All the overflow data from macro-block 101 is filled into the finished blocks in macro-block 101. For example, consider the first macro-block 101. Blocks 101a, 101c, 101d, and 101e are unfinished blocks and blocks 101b and 101f are finished blocks with extra storage space available to hold additional overflow data. During pass two, the overflow data from block 101a is first used to fill block 101b and then used to fill block 101f. If there is still additional overflow data from block 101a after blocks 101b and 101f are completely filled, the overflow data remains in the separate memory until pass three. Pass two is limited to a single macro-block, e.g., macro-block 101. Hence, the overflow data from unfinished blocks of macro-blocks 101, 102, 103, 104, and 105 are filled into the finished block of macro-block 101, 102, 103, 104, and 105, respectively.
For pass three, the remaining overflow data stored in memory, that is the overflow data that was not removed from the separate memory during pass two, will be filled into the first available block. That is, during pass three, the overflow data is stored into a block even if the block is in a different macro-block. For example, overflow data from block 104d is filled into the first available block, which can be block 105d. 
Arranging compressed video segment data using three passes requires extra memory for overflow data resulting from pass one and pass two so that the overflow data can be filled in a later pass, such as pass two and pass three.
The present invention relates to new and improved methods and apparatus for code packing in a digital video system. Among others, a method of transferring a data block to a storage device is disclosed. The storage device can include a plurality of compartments. The method includes receiving a plurality of length values. Each length value can correspond to a data block from a plurality of data blocks. The method further includes filling a first compartment of the storage device with a portion of data from a first data block, searching the length values to identify one of the plurality of data blocks having a length value less than a threshold value, and filling a second compartment with a remaining portion of the data from the first data block. In one embodiment, the second compartment can correspond to the identified data block.
In separate alternate embodiments, the method can further comprise filling a second compartment of the storage device with either a portion or an entire portion of data from a second data block. In another embodiment, the threshold value defines the storage capacity of at least one of the plurality of compartments.
In yet another embodiment, a compression module compresses video segment data and transfers the compressed video segment data to a code packing module. The code packing module arranges the compressed video segment data in a storage device such as a memory. The code packing module can arrange and store the compressed video segment data into a number of compartments in the storage device. In one embodiment, the compressed video segment data can be divided into five macro-blocks. Each macro-blocks can be divided into a number of blocks, e.g., six blocks. An encoder determines and transmits a length value for each of the blocks to the code packing module. The length value can represent the amount of compressed video segment data that can be stored in a particular block. Alternatively, the length value can represent the amount of compressed video segment data that is stored in a particular block. The code packing module fills a first compartment of the storage device with at least a portion of the data from a first block. If all the data from the first block can be stored in the first compartment then a second block of data is arranged and stored in a second compartment. If all the data from the first block cannot be stored in the first compartment, then the code packing module searches the length values to identify one of the data blocks having a length value less than a threshold value.
In a further embodiment, the threshold value can be the storage capacity of at least one of the compartments in the storage device. Furthermore, one or more threshold values can be used for the storage device.
In yet a further embodiment, the second compartment can correspond to the identified data block. In another embodiment, the compartments in the storage device can be arranged in a similar manner as the compressed data blocks.
Advantages of the invention include eliminating the need to store the overflow data in a separate memory. Further, one aspect of the invention provides for the arrangement of a video segment in a single pass thereby reducing the amount of time required to pack a video segment. Additionally, the invention has enhanced efficiency and requires less hardware to pack a video segment. Also, shared hardware can be used to calculate the overflow data, underflow data, and pointers to various locations in a particular compartment.